/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kcollgen;

import java.util.ArrayList;

/**
 *
 * @author Pierre
 */
public class Collection {
    
    String colName;
    ArrayList<String> hashes;

    public Collection(String colName) {
        this.colName = colName;
        this.hashes = new ArrayList<String>();
    }
    
    void addSha1(String sha1){
        for(String s : hashes)
            if(s.equals(sha1)){
                System.out.println("Error : sha1 already present in collection " + colName);
                return;
            }
        hashes.add(sha1);
    }
    
    String getKindleString(){
        String res = "";
        
        res += "\"" + colName + "@en-US\"";
        res += ":{\"items\":[";
        
        /* Ajout elements */
        for(String h : hashes){
            res += "\"*" + h + "\"";
            if(hashes.indexOf(h) != hashes.size()-1)
                res +=",";
        }
        
        res += "],\"lastAccess\":0}";
        
        return res;
    }
    
}
